package com.jqr.activity.mycoroutine.viewmodels

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.jqr.activity.mycoroutine.models.Articles
import com.jqr.activity.mycoroutine.respository.ArticlesRepository
import kotlinx.coroutines.launch

class MainViewModel  :ViewModel(){
    val articleLiveData=MutableLiveData<Articles>()

    private val articlesRepository=ArticlesRepository()

    fun  getArticles(){
       viewModelScope.launch {
           val articles=articlesRepository.getAllArticles()
            articleLiveData.value=articles
        }

    }

}